<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<title>文档 - 分享文档</title>
	<div th:replace="common/head">head</div>
    <style type="text/css">
    .header {top: 0; box-shadow: 0 1px 12px rgba(16, 6, 25, 0.2); z-index: 999;}
    .footer {background-color: #ffffff;}
    </style>
</head>

<body>
<div th:replace="common/nav::nav(pageName='doc')">nav</div>
<section style="background: #e5e8ec; overflow: hidden; padding-top: 75px;">
    <div id="doc-list" class="main">
        <div class="common-box">
            <ul class="doc-index-list">
                
            </ul>
        </div>
        <div class="fly-none layui-hide" style="min-height: 256px; padding-top: 20px;">
            <h2><i class="iconfont icon-meiyouxiaoxi"></i></h2>
            <p style="margin-top: 5px; font-size: 22px">还没有人分享文档</p>
            <p style="margin-top: 5px; font-size: 22px"><a th:href="@{/doc/upload/}" class="layui-inline site-up">立即分享</a> </p>
        </div>
    </div>
    <div class="clearfix"></div>
</section>

<div th:replace="common/footer">footer</div>
</body>
<script th:src="@{/static/layui/layui.js}"></script>
<script type="text/javascript">
layui.config({
    base: '[[@{/static/mods/}]]'
}).extend({
    izerofx: 'index'
}).use('izerofx');
</script>
<script type="text/javascript">
layui.use(['flow','layer','laytpl'], function(){
    var $ = layui.jquery
    ,layer = layui.layer
    ,laytpl = layui.laytpl
    ,flow = layui.flow;
    
    var tpl = '{{# for(var i = 0; i < d.list.length; i++){ }}\
        <li>\
            <div class="books">\
                <a href="'+BASE_URL+'doc/P-{{=d.list[i].id}}.html" target="_blank" style="background-color:#FFF">\
                    <img lay-src="'+BASE_URL+'{{d.list[i].thumPath}}">\
                </a>\
                <em>P.{{d.list[i].pages}}</em>\
            </div>\
            <div class="names">\
                <h3>\
                    <a href="'+BASE_URL+'doc/P-{{=d.list[i].id}}.html" target="_blank">{{=d.list[i].title}}</a>\
                </h3>\
                <h4><a href="'+BASE_URL+'user/u/{{d.list[i].userId}}" target="_blank">{{=d.list[i].nickName}}</a></h4>\
            </div>\
        </li>\
      {{# } }}';
      
    flow.load({
        elem: '.doc-index-list'
        ,isAuto: true
        ,isLazyimg: true
        ,done: function(page, next){
	        $.ajax({
	            type: 'post',
	            dataType: 'json',
	            data: {
	               p: page
	            },
	            url: BASE_URL + 'doc/list/',
                success: function(res){
                    if(res.status === 0) {
                        if(page == 1 && res.total == 0){
                            $(".fly-none").removeClass("layui-hide");
                            $(".doc-index-list").addClass("layui-hide");
                            next('', 0);
                        }else{
                            var html = laytpl(tpl).render(res);
                            next(html, res.list.length < 10 ? 0 : 10);
                        }
	                } else {
                        layer.msg(res.msg||res.code, {shift: 6});
	                }
	            },
                error: function(e){
                    layer.msg('请求异常，请重试', {shift: 6});
	            }
	        });
        }
    });
});
</script>
</html>